package advanced进阶;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 线程本地变量
 */
//两个线程对日期进行初始化
public class ThreadLocal {
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            Date date = new Date(1 * 1000);//1s
            System.out.println(dateFormat(date));
        });
        Thread t2 = new Thread(()->{
            Date date = new Date(1 * 1000);//1s
            System.out.println(dateFormat(date));
        });
        t1.start();
        t2.start();
    }

    private static String dateFormat(Date date) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("mm:ss");
        return simpleDateFormat.format(date);
    }
}
